<template>
  <el-container class="main-container">
    <!-- 头部布局 -->
    <el-header>
      <!-- logo和系统名称 -->
      <div class="left-box">
        <img src="../assets/img/logo.png" />
        <span>勤工俭学管理系统</span>
      </div>
      <!-- 登录的用户名 -->
      <div class="right-box">
        <el-dropdown trigger="click" @command="handleCommand">
          <span class="el-dropdown-link">
            张三
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="a" icon="el-icon-house">
              系统首页
            </el-dropdown-item>
            <el-dropdown-item command="b" icon="el-icon-user"
              >个人信息</el-dropdown-item
            >
            <el-dropdown-item command="c" icon="el-icon-switch-button"
              >退出登录</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>

    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200px">
        <el-menu
          default-active="1"
          class="el-menu-vertical-demo"
          background-color="#b3c0d1"
          text-color="#333"
          active-text-color="#ffd04b"
          :router="true"
        >
          <MenuTree :MenuList="this.MenuList"></MenuTree>
        </el-menu>
      </el-aside>

      <el-main>
        <router-view> </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import MenuTree from "../components/MenuTree.vue";
import MenuData from "../json/MenuTree.json";

export default {
  data() {
    return {
      MenuList: MenuData.data,
    };
  },
  components: {
    MenuTree,
  },
  methods: {
    handleCommand(command) {
      switch (command) {
        case "a":
          this.$router.push('/index');
          break;
        case "b":
           this.$router.push('/adminInfo');
          break;
        case "c":
          this.$router.push('/');
          break;
        default:
          break;
      }
    },
  },
};
</script>

<style lang="less" scope>
/* 页面整体高度 */
.main-container {
  height: 100%;
}

/* 头部布局 */
.el-header {
  background-color: #b3c0d1;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  color: #333;
  align-items: center;
  font-size: 20px;

  /* 左边logo和标题 */
  .left-box {
    display: flex;
    align-items: center;

    /* logo */
    img {
      width: 60px;
      height: 60px;
      margin: 0px 10px 10px 10px;
    }
  }

  /* 右边用户名和下拉菜单 */
  .right-box {
    /* 用户名样式 */
    .el-dropdown-link {
      cursor: pointer;
      color: #333;
      font-weight: bold;
    }
  }
}

/* 左侧边栏 */
.el-aside {
  background-color: #b3c0d1;
  color: #333;

  .el-menu {
    border: none;
  }
}

/* 内容主体 */
.el-main {
  background-color: #e9eef3;
  color: #333;
}
</style>